home *** CD-ROM | disk | FTP | other *** search
/ Stone Design / Stone Design.iso / Stone_Friends / Wave / WavesWorld / Source / IBPalettes / WW3DKit / RIBSolidBegin.m < prev    next >
Encoding:
Text File  |  1995-03-22  |  1.8 KB  |  97 lines

  1. // copyright 1993 Michael B. Johnson; some portions copyright 1994, MIT
  2. // see COPYRIGHT for reuse legalities
  3. //
  4.  
  5. #import "RIBSolidBegin.h"
  6.  
  7. @implementation RIBSolidBegin
  8.  
  9. + initialize { return [RIBSolidBegin setVersion:1], self; }
  10.  
  11. - init
  12. {
  13.   [super init];
  14.  
  15.   operation = RI_PRIMITIVE;
  16.   
  17.   return self;
  18. }
  19.  
  20. - (BOOL)pushesOrPopsCTM { return YES; }
  21. - (BOOL)pushesCTM { return YES; }
  22.  
  23. - setOperation:(RtToken)opName
  24. {
  25.   if (!strcmp(opName, RI_PRIMITIVE))
  26.   {  operation = RI_PRIMITIVE;
  27.      return self;
  28.   }
  29.   if (!strcmp(opName, RI_INTERSECTION))
  30.   {  operation = RI_INTERSECTION;
  31.      return self;
  32.   }
  33.   if (!strcmp(opName, RI_UNION))
  34.   {  operation = RI_UNION;
  35.      return self;
  36.   }
  37.   if (!strcmp(opName, RI_DIFFERENCE))
  38.   {  operation = RI_DIFFERENCE;
  39.      return self;
  40.   }
  41.  
  42.   NXLogError("unknown solid operation <%s> in RIBCommand RIBSolidBegin ", opName);
  43.   NXLogError("- supported operations are: primitive, intersection, union, difference.\n");
  44.   return nil;
  45. }
  46.  
  47. - (RtToken)operation { return operation; }
  48.  
  49. - renderSelf:(WW3DCamera *)camera startingAt:(RtFloat)shutterOpenTime endingAt:(RtFloat)shutterCloseTime
  50. {
  51.   RiSolidBegin(operation);
  52.  
  53.   return self;
  54. }
  55.  
  56. - writeEve:(NXStream *)stream atTabLevel:(int)tab
  57. {
  58.    int  i;
  59.  
  60.  
  61.    for (i = 0; i < tab; i++)
  62.    {  NXPrintf(stream, "\t");
  63.    }
  64.    NXPrintf(stream, "SolidBegin %s;", operation); 
  65.    return self;
  66. }
  67.  
  68. #define typeVector "*"
  69. #define typeValues &operation
  70.  
  71. - read:(NXTypedStream*)stream 
  72. {
  73.     int version;
  74.     [super read:stream];
  75.  
  76.     version = NXTypedStreamClassVersion(stream,"RIBSolidBegin");
  77.     if (version == 0) NXReadTypes(stream, "i", &version), version=1;
  78.     if (version == 1)
  79.     {  NXReadTypes(stream, typeVector, typeValues);
  80.     } 
  81.     else 
  82.     {
  83.     }
  84.     return self;
  85. }
  86.  
  87. - write:(NXTypedStream*)stream 
  88. {
  89.     [super write:stream];
  90.  
  91.     NXWriteTypes(stream, typeVector, typeValues);
  92.  
  93.     return self;
  94. }
  95.  
  96. @end
  97.